//
//  HJChatMessageKeyboardReplyCell.m
//  KaiChat
//
//  Created by lx on 2023/12/25.
//

#import "HJChatMessageKeyboardReplyCell.h"
#import "HJChatMessageKeyboardReplyLayout.h"
#import "HJChatMessageModel.h"
#import "HJGradientView.h"
#import "QMUIButton.h"

@interface HJChatMessageKeyboardReplyCell()

@property (nonatomic, weak) UILabel *contentLabel;
@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UIImageView *coverImageView;

@end


@implementation HJChatMessageKeyboardReplyCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        UIImageView *coverImageView = [UIImageView addToView:self.bubbleView];
        coverImageView.clipsToBounds = YES;
        coverImageView.contentMode = UIViewContentModeScaleAspectFill;
 
        UILabel *titleLabel = [UILabel lableWithSuperView:self.bubbleView font:UIFontMediumMake(14) color:UIColor.tj_333333Color title:nil textAlignment:NSTextAlignmentLeft];
        titleLabel.numberOfLines = 1;

        UILabel *contentLabel = [UILabel addToView:self.bubbleView];
        contentLabel.textAlignment = NSTextAlignmentLeft;
        contentLabel.textColor = UIColor.tj_868391Color;
        contentLabel.numberOfLines = 2;
        
        _contentLabel = contentLabel;
        _titleLabel = titleLabel;
        _coverImageView = coverImageView;
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    HJChatMessageKeyboardReplyLayout *messageKeyboardReplyLayout = (HJChatMessageKeyboardReplyLayout *)self.messageLayout;
    _coverImageView.frame = messageKeyboardReplyLayout.coverViewRect;
    _titleLabel.frame = messageKeyboardReplyLayout.titleLabelRect;
    _contentLabel.frame = messageKeyboardReplyLayout.contentRect;
}

- (void)setMessageLayout:(HJChatMessageLayout *)messageLayout {
    [super setMessageLayout:messageLayout];
    
    HJChatMessageKeyboardReplyLayout *messageKeyboardReplyLayout = (HJChatMessageKeyboardReplyLayout *)self.messageLayout;
    self.avatarImageView.hidden = YES;
    self.nameLabel.hidden = YES;
    [self.coverImageView tj_setImageWithUrl:messageKeyboardReplyLayout.coverUrl placeholderImage:[UIImage imageNamed:@"bigLoad"]];
    
    self.titleLabel.font = messageKeyboardReplyLayout.titleLabelFont;
    self.contentLabel.font = messageKeyboardReplyLayout.contenFont;
    self.contentLabel.attributedText = messageKeyboardReplyLayout.attributedString;
    self.titleLabel.text = messageKeyboardReplyLayout.title;
}


@end
